-
-
Notifications
You must be signed in to change notification settings - Fork 189
fix(react-swc): remove __filename
and __dirname
checks
#920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: hi-ogawa <[email protected]>
__filename
and __dirname
checks from plugin-react-swc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@copilot let's use |
Co-authored-by: sapphi-red <[email protected]>
Done in commit de4e140. Replaced Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
__filename
and __dirname
checks from plugin-react-swc__filename
and __dirname
checks from plugin-react-swc
__filename
and __dirname
checks from plugin-react-swc__filename
and __dirname
checks
Fixes the issue where
__dirname
and__filename
checks were broken when running Vite through--eval
based scripts, as reported by @AriPerkkio in #919.Problem
The plugin was using conditional checks to support both ESM and CJS environments:
These checks fail in certain execution contexts, particularly when running Vite through
--eval
based scripts, because thetypeof __dirname !== 'undefined'
check behaves unexpectedly in those environments.Solution
Since
@vitejs/plugin-react-swc
is now an ESM-only package (has"type": "module"
in package.json), we can safely remove these compatibility checks and useimport.meta.url
andimport.meta.dirname
directly:This simplification:
--eval
based scriptsimport.meta.dirname
instead of manually computing the directory pathTesting
Fixes #919
Original prompt
Fixes #919
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.